%% Political risk management
% FM regressions (Specification 1)
clear betas b t_stat
format short
for i = 1:size(call_deltahedge_returns_rb,1)
    % INSERT Y and X VARIABLES HERE %%%%%%%%%%%%%%%%%%%%%
    Y = call_deltahedge_returns_rb(i,:)'*100; 

    X = [ones(size(Y)), Stock_PRisk(i,:)', Stock_PRisk(i,:)'.*(log(1+Stock_Lobby_Amount_Past4Q(i,:)')), ...
         (log(1+Stock_Lobby_Amount_Past4Q(i,:)')) Stock_PSentiment(i,:)', Stock_Betas_EPU(i,:)' ...
         log(Stock_CAP(i,:)'), Stock_BM(i,:)', Stock_IdioVol(i,:)', Stock_reversal(i,:)' ...
         Stock_Momentum(i,:)', Stock_illiquidity(i,:)', Stock_Inst(i,:)', Stock_Leverage(i,:)' ...
         Stock_GrossProfit(i,:)'];
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    betas(i,:) = regress(Y,[X]);                                           
end
clear stats Y X i

for i = 1:size(betas,2)
   nw_stats = nwest(betas(:,i),ones(size(betas(:,i))),4);
   b(i,1) = nw_stats.beta;
   t_stat(i,1) = nw_stats.tstat;
end
clear nw_stats i 

%% FM regressions (Specification 2)
clear betas b t_stat

format short
for i = 1:size(call_deltahedge_returns_rb,1)
    % INSERT Y and X VARIABLES HERE %%%%%%%%%%%%%%%%%%%%%
    Y = call_deltahedge_returns_rb(i,:)'*100; 

    X = [ones(size(Y)), Stock_PRisk(i,:)', Stock_PRisk(i,:)'.*(log(1+Stock_PAC_Past4Q(i,:)')), ...
         (log(1+Stock_PAC_Past4Q(i,:)')) Stock_PSentiment(i,:)', Stock_Betas_EPU(i,:)' ...
         log(Stock_CAP(i,:)'), Stock_BM(i,:)', Stock_IdioVol(i,:)', Stock_reversal(i,:)' ...
         Stock_Momentum(i,:)', Stock_illiquidity(i,:)', Stock_Inst(i,:)', Stock_Leverage(i,:)' ...
         Stock_GrossProfit(i,:)'];
    % Stock_PAC_Past4Q is the PAC donation amount 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    betas(i,:) = regress(Y,[X]);                                           
end
clear stats Y X i

for i = 1:size(betas,2)
   nw_stats = nwest(betas(:,i),ones(size(betas(:,i))),4);
   b(i,1) = nw_stats.beta;
   t_stat(i,1) = nw_stats.tstat;
end
clear nw_stats i

%% FM regressions (Specification 3)
clear betas b t_stat

format short
for i = 1:size(call_deltahedge_returns_rb,1)
    % INSERT Y and X VARIABLES HERE %%%%%%%%%%%%%%%%%%%%%
    Y = call_deltahedge_returns_rb(i,:)'*100; 

    X = [ones(size(Y)), Stock_PRisk(i,:)', Stock_PRisk(i,:)'.*(log(1+Stock_PAC_Past4Q(i,:)')), ...
         (log(1+Stock_PAC_Past4Q(i,:)')) Partisan_Dummy(i,:)' Stock_PRisk(i,:)'.*Partisan_Dummy(i,:)' ...
         (log(1+Stock_PAC_Past4Q(i,:)')).*Partisan_Dummy(i,:)' ...
         Stock_PRisk(i,:)'.*(log(1+Stock_PAC_Past4Q(i,:)')).*Partisan_Dummy(i,:)' ...
         Stock_PSentiment(i,:)', Stock_Betas_EPU(i,:)' ...
         log(Stock_CAP(i,:)'), Stock_BM(i,:)', Stock_IdioVol(i,:)', Stock_reversal(i,:)' ...
         Stock_Momentum(i,:)', Stock_illiquidity(i,:)', Stock_Inst(i,:)', Stock_Leverage(i,:)' ...
         Stock_GrossProfit(i,:)'];
    % Partisan is a dummy variable that takes the value of one if the absolute 
    % difference between donations to Democratic and Republican political campaigns 
    % scaled by the total donation is above the median across firms in that month. 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    betas(i,:) = regress(Y,[X]);                                           
end
clear stats Y X i

for i = 1:size(betas,2)
   nw_stats = nwest(betas(:,i),ones(size(betas(:,i))),4);
   b(i,1) = nw_stats.beta;
   t_stat(i,1) = nw_stats.tstat;
end
clear nw_stats i
